package com.tsxy.mall.controller;

import com.tsxy.mall.entity.Book;
import com.tsxy.mall.mapper.BookMapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.catalina.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class IndexController {
    Logger logger = LoggerFactory.getLogger("IndexController");
    @Autowired
    private BookMapper bookMapper;

    @RequestMapping("/")
    public String toIndex(HttpServletRequest request){
        return "index";
    }

    @RequestMapping("/user")
    @ResponseBody
    public List<Book> user(){
        return bookMapper.getAll();
    }
}
